#pragma once

#include "article.h"

#include <fstream>
#include <iostream>
using namespace std;

template <int n>
class Bucket
{
public:
    const static int sizeArticle = sizeof(Article);
    const static int sizeBucket = sizeArticle * n + sizeof(int);

    Bucket() { m_hashDigitCount = -1; }

    void write(int position, std::fstream * fileStream);
    void read(int position, std::fstream * fileStream);

    bool addArticle(Article *article);
    Article * getArticle(int position) { return &(slots[position]); }

    int getHashDigitCount() const { return m_hashDigitCount; }
    void setHashDigitCount(int hashDigitCount) { m_hashDigitCount = hashDigitCount; }

    friend ostream & operator << <>(ostream &os, const Bucket<n> & bucket);

private:
    Article slots[n];
    int m_hashDigitCount;
};
